import { _decorator, Component, director, Label, find, ProgressBar, Sprite, tween, UIOpacity } from 'cc';
import Banner from '../Manager/Banner';
const { ccclass, property } = _decorator;

@ccclass('LoadingPanel')
export class LoadingPanel extends Component {


    onLoad() {
        // var progressBar = find("BG/LoadingBar/ProgressBar", this.node).getComponent(Sprite);
        // var progressLb = find("BG/LoadingBar/ProgressLabel", this.node).getComponent(Label);

        director.preloadScene("Gameing", (completedCount: number, totalCount: number, item: any) => {
            // var progress = completedCount / totalCount;
            // progressBar.fillRange = progress;
            // progressLb.string = `正在加载：${(progress * 100).toFixed()}%`;
        }, () => {
            director.loadScene("Gameing");
        });
    }

    protected start(): void {
        let loading = find("Canvas/LoadingImg");
        let label = find("Canvas/Label");
        tween(loading)
            .to(1, { angle: 360 })
            .call(() => {
                loading.angle = 0;
            })
            .union()
            .repeatForever()
            .start();
        tween(label.getComponent(UIOpacity))
            .to(1, { opacity: 0 })
            .to(0.5, { opacity: 255 })
            .union()
            .repeatForever()
            .start();
    }

}